home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-11-16 | 15.2 KB | 552 lines | [TEXT/MPS ] |
- ;
- ; File: ShowINIT.a
- ;
- ; Contains: xxx put contents here xxx
- ;
- ; Written by: xxx put writers here xxx
- ;
- ; Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
- ;
- ; Change History (most recent first):
- ;
- ; <4> 9/9/92 MK do masking the right way
- ; <3> 8/11/92 MK take out stupid debugger break
- ; <2> 8/11/92 MK fix register trashing bug
- ; <1> 8/4/92 MK first checked in
- ;
- ;
-
- ; File: ShowINIT.a
- ; Last Modified: Friday, Jan 15, 1991
- ;------------------------------------------------------------------------------------------------
- ;
- ; INIT notification routine
- ; by Paul Mercer, Darin Adler, and Paul Snively from an idea by Steve Capps
- ; icl4/icl8 support by Brad Lowe
- ;
- ; Created: 6/7/87 PM - First version.
- ; Modified: 6/15/87 PM - Changed to standard (Pascal) calling conventions.
- ; 6/20/87 PM - Fixed color & Finder bug on Mac II.
- ; 6/22/87 DBA - Improved handling of QuickDraw.
- ; 6/29/87 DBA - Used scratch8 to avoid conflict with “Easy Access”.
- ; 6/30/87 DBA - Changed to a 4-byte scheme with “checksum”.
- ; 6/30/87 PFS - Separated into ShowINIT and InnerShowINIT.
- ; 7/1/87 DBA - Fixed stack bug and switched to CurApName+.
- ; 7/2/87 PM - Added check for old signature in ApplScratch for
- ; backword compatibility (TMON Startup).
- ; 7/3/87 PM - Removed _SysBeep in ErrorExit since it causes a crash.
- ; Also changed ICN# plotter to srcOr mode for Blinker.
- ; 7/13/87 PM - Fixed a3 trashing bug in InnerShowINIT - exit code left
- ; word on stack (reported by D. Dunham).
- ; 7/21/87 PM - Due to popular demand, InitGraf is no longer being called.
- ; This avoids the gamma correction problem with Startupscreens
- ; getting “washed out” by ShowINIT though someone else is still
- ; bound to call InitGraf sooner or later (i.e. InitWindows).
- ; 7/29/87 PM - Put InitGraf back in; this is required (reported by C. Derossi
- ; at Apple Tech Support). Took out GetPort/SetPort.
- ; 10/06/87 PM - Set CurrentA5 properly. Rearranged myVars.
- ; 12/28/87 PM - Major revision to accomodate future INIT31 based ShowINIT.
- ; 07/14/88 PM - Major revision to get rid of above 'accomodations'.
- ; Added color icon 'cicn' support and fixed beep crash.
- ; Removed support for old signature.
- ; 1/21/91 BL - Added support for icl4's and icl8's. Removed support for
- ; for cicn's. An ICN# must be included for each color icl you want
- ; displayed (to draw the mask, and for when there is no color or less
- ; than 4 bit color.) Showinit displays either an icl4, icl8, or a black
- ; and white ICN#, depending on what resources are present, and the color
- ; depth available.
- ;
- ;------------------------------------------------------------------------------------------------
-
- INCLUDE 'Traps.a'
- INCLUDE 'QuickEqu.a'
- INCLUDE 'SysEqu.a'
- INCLUDE 'ToolEqu.a'
-
- BLANKS ON
- STRING ASIS
-
- True equ 1
- False equ 0
-
- Debug equ True
- ;Debug equ False
-
- myH equ CurApName+32-4 ; a GREAT place to store 4 bytes (it was Darin's idea)
- myCheck equ myH+2 ; a simple checksum of myH to determine first-timeness
- firstX equ 8 ; X coordinate of first icon to be drawn
- bottomEdge equ 8+32 ; this far from bottom of screen
- iconWidth equ 32 ; size of icon (square normally)
- defaultMoveX equ 40 ; default amount to move icons
- checksumConst equ $1021 ; constant used for computing checksum
- minColorDepth equ 4 ; minimum bits/pixel for drawing color icons
-
- maskOffset equ 128 ; offset to mask in ICN#
- iconRowBytes equ 32/8 ; 32/8 bits
-
- hasCQDBit equ 6 ; this bit in ROM85 is cleared if Color QuickDraw is available
-
- iconID equ 6+4 ; positive stackframe objects
- showINITArgs equ 4
-
-
- ; INITDraw1Bit arguments
- moveX equ 4+4 ; a short
- iconPtrHdl equ 6+4 ; a long
- theIconID equ 10+4 ; added
- initDrawArgs equ 8 ; was 6
-
- myVars RECORD 0,DECREMENT
- saveA5 ds.l 1
- localA5 ds.l 1
- thePort ds.l 1 ; my own QuickDraw (required!)
- ds.b grafSize-4 ; other QuickDraw globals (except thePort)
-
- destRect ds.w 4
- myBitMap ds.b bitMapRec
- myPort ds.b portRec
- icl4Hand ds.l 1
- icl8Hand ds.l 1
-
- varsSize equ *
- ENDR
-
- ; DrawIcls routine...
- iclVars RECORD 0,DECREMENT
- pixMap ds.b pmRec
- GDHand ds.l 1
- iclVarSize equ *
- ENDR
-
- ; iclDraw arguments
- pixSize equ 4+4 ; either 4, 8, (or higher)
- DestPM equ 6+4 ; the dest rect pointer
- destRect equ 10+4 ; dest pixmap (ptr) for copybits
- iclHand equ 14+4 ; handle of icl... assumed to be good
- iclDrawArgs equ 14 ;
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; Displays the ICN# (cicn when in 4 bit mode or higher) specified by iconID and
- ; move the pen horizontally by moveX.
- ; Pass a -1 in moveX to move the standard amount, moveX should be 40 for most ICN#'s
- ;
- ; PROCEDURE ShowINIT(iconID: Integer; moveX: Integer); EXTERNAL
- ;
- ; pascal void ShowINIT(iconID, moveX)
- ; short iconID, moveX;
- ; extern;
- ;
- ;------------------------------------------------------------------------------------------------
- ShowINIT: PROC EXPORT
- IMPORT INITDraw1Bit
- link a6,#0 ; create stack frame
- movem.l d3-d7/a2-a4,-(sp) ; save standard registers
-
- ShowINIT1Bit
-
- clr.l -(sp) ; try to get the ICN# resource
- move.l #'ICN#',-(sp)
- move.w iconID(a6),-(sp)
- _GetResource
- move.l (sp)+,A0
-
- Move.l A0, D0
-
- beq.s ShowINITError ; can't get it, give up
-
- _HLock ; Lock the ICN# resource in A0
- Move.l A0, D0
-
- move.l d0,-(sp) ; leave handle on the stack for ReleaseResource
- move.l d0,a0
- move.l (a0),a0 ; dereference
-
- move.w iconID(a6), -(sp) ; the icon id, for icl4, icl8 -- BL
- move.l a0,-(sp) ; icon pointer (iconPtrHdl)
- move.w moveX(a6),-(sp) ; moveX (MoveX)
-
- bsr INITDraw1Bit ; draw
-
- _ReleaseResource ; releaese the resource
-
- ShowINITExit:
-
- movem.l (sp)+, d3-d7/a2-a4 ; restore registers
- unlk a6 ; ditch stack frame
- move.l (sp)+, a0 ; get return address
- addq.l #showINITArgs, sp ; ditch incoming arguments
- jmp (a0) ; return to caller
-
- ShowINITError:
- IF Debug THEN
- move.w #1,-(sp) ; just beep
- _SysBeep
- ENDIF
- bra.s ShowINITExit
-
- ShowINITCredits:
- dc.w 'ShowINIT by Paul Mercer'
- dc.w 'modified 1/22/91 to show'
- dc.w 'icl4 and icl8 types'
- ENDPROC
-
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; Initializes the world and sets up the drawing rectangle
- ;
- ;------------------------------------------------------------------------------------------------
- INITInit: PROC EXPORT
- WITH myVars
-
- move.l CurrentA5,saveA5(a6) ; PM 10/6 save host A5
- lea localA5(a6),a5 ; PM7/21
- move.l a5,CurrentA5
- pea thePort(a6) ; PM 10/6 use a5 reference instead of a6
- _InitGraf ; fixes color bug as per DA@ICOM
- pea myPort(a6)
- _OpenPort
-
- move.w myH,d0 ; get my h var
- rol.w #1,d0 ; compare against checksum
- eor.w #checksumConst,d0
- cmp.w myCheck,d0
- beq.s ScratchOK ; checks, so go on
- move #firstX,myH ; else initialize as first time
- ScratchOK:
- lea myPort(a6),a0 ; compute the destination rectangle
- move.w portBounds+bottom(a0),d0
- sub.w #bottomEdge,d0
- swap d0
- move.w myH,d0
-
- move.l d0,destRect(a6)
- move.l d0,destRect+botRight(a6)
- add.w #iconWidth,destRect+right(a6)
- add.w #iconWidth,destRect+bottom(a6)
-
- rts
-
- ENDWITH
- ENDPROC
-
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; Cleans up the work done by INITInit and advances the icon drawing position
- ;
- ;------------------------------------------------------------------------------------------------
- INITCleanup: PROC EXPORT
- WITH myVars
-
- move.w myH,d0 ; get current position
- move.w moveX(a6),d1 ; get delta x
- bpl.s NotDefault ; not default (-1)
- move.w #defaultMoveX,d1 ; default
- NotDefault:
- add.w d1,d0 ; increment icon position
- move.w d0,myH ; and save in ‘global’
- rol.w #1,d0 ; recompute checksum
- eor.w #checksumConst,d0
- move.w d0,myCheck ; and save it
- Exit:
- pea myPort(a6)
- _ClosePort
- ; *** (DBA) I think that QuickDraw leaves handles around.
- ; *** (DBA) Too bad we can't get rid of them...
- move.l saveA5(a6),a5 ; PM 10/6 restore host A5
- move.l a5,CurrentA5
- rts
-
- ENDWITH
- ENDPROC
-
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; display the ICN# pointed to by iconPtr and move the pen horizontally by moveX
- ; pass a -1 in moveX to move the standard amount, moveX should be 40 for most ICN#'s
- ;
- ; PROCEDURE INITDraw1Bit(iconPtr: ICONListPtr; moveX: Integer); EXTERNAL
- ;
- ; pascal void INITDraw1Bit(iconPtr, moveX)
- ; ICONList *iconPtr;
- ; short moveX;
- ; extern;
- ;
- ;------------------------------------------------------------------------------------------------
- INITDraw1Bit: PROC EXPORT
- IMPORT INITInit, INITCleanup:CODE
- IMPORT DrawIcls ; plots icl4 or icl8..
-
- WITH myVars
-
- link a6,#varsSize ; create stack frame
- movem.l d3-d7/a2-a4,-(sp) ; save standard registers
- bsr INITInit ; initialize for drawing
-
- clr.l icl4Hand(a6) ;
- clr.l icl8Hand(a6)
-
- btst.b #hasCQDBit,ROM85 ; try to get a color icon if CQD exists
- bne.s DrawMask ; I could use SysEnvirons but I don't want to
-
- ; //// Try and load an icl4 and icl8
- ; Get the resources here so there won't be a delay after drawing the mask...
- ; Get both- their small, and just use what we need and toss anything not nil back later...
-
- clr.l -(sp) ; try to get an icl4 resource
- move.l #'icl4',-(sp)
- move.w theIconID(a6),-(sp)
- _GetResource
- move.l (sp)+, icl4Hand(A6);
-
- clr.l -(sp) ; try to get icl8 resource
- move.l #'icl8', -(sp)
- move.w theIconID(a6),-(sp)
- _GetResource
- move.l (sp)+,icl8Hand(A6);
-
- DrawMask:
-
- lea myPort(a6),a2 ; get the desk port
-
- move.l iconPtrHdl(a6),a3 ; get ICN# pointer
- lea myBitMap(a6),a4 ; point to bitmap structure
- move.l a3,baseAddr(a4) ; fill it out
- add.l #maskOffset,baseAddr(a4) ; skip to mask
- move #iconRowBytes,rowBytes(a4)
- move.l #0,bounds(a4) ; 0,0 topleft
- move.w #iconWidth,bounds+bottom(a4) ; 32,32 botright
- move.w #iconWidth,bounds+right(a4)
-
-
- btst.b #hasCQDBit,ROM85 ; try to get a color icon if CQD exists
- bne DrawBW ;
-
-
-
- ; Get depth of main screen...
- move.l MainDevice,a3 ; get handle to main device
- move.l (a3),a3 ; dereference
- move.l gdPMap(a3),a3 ; get its pixmap handle
- move.l (a3),a3 ; dereference it
-
- cmp.w #minColorDepth, pmPixelSize(a3); Pixel depth less than 4?
- blt DrawBW
-
- clr.l -(sp)
- _NewRgn
- move.l a4,-(sp)
- move.l 4(sp),a4
- _BitMapToRegion
- addq.l #2,sp
- move.l a4,-(sp)
- move.w destRect+left(a6),-(sp)
- move.w destRect+top(a6),-(sp)
- _OffsetRgn
-
- cmp.w #8, pmPixelSize(a3); Use routine for 8 bit and higher screens
- bge.s Handle8Bit
-
- ; This is Handle4Bit (must be 4 bit)
-
- cmp.l #0, icl4Hand(a6)
- beq.s try8
- ; draw a icl4 in 4 bit mode, this is the best combination
-
- ; -------
- move.l icl4Hand(a6), -(sp) ; the icl handle
- pea destRect(a6)
- pea portBits(a2) ; for copybits...
- move.w #4, -(sp) ; depth of main screen
- bsr DrawIcls;
- ; -------
-
- bra DoneDrawing
-
- try8: cmp.l #0, icl8Hand(a6)
- beq.s DrawBW
- ; draw a icl8 in 4 bit mode
- ; -------
- move.l icl8Hand(a6), -(sp) ; the icl handle
- pea destRect(a6)
- pea portBits(a2) ; for copybits...
- move.w #8, -(sp) ; depth of main screen
- bsr DrawIcls;
- ; -------
- bra.s DoneDrawing
-
- Handle8Bit: ; Handle 8 bit (and higher) screens..
- cmp.l #0, icl8Hand(a6)
- beq.s try4
- ; draw a icl8 in 8 bit mode
- ; -------
- move.l icl8Hand(a6), -(sp) ; the icl handle
- pea destRect(a6)
- pea portBits(a2) ; for copybits...
- move.w #8, -(sp) ; depth of icl
- bsr DrawIcls;
- ; -------
- bra.s DoneDrawing
-
- try4: cmp.l #0, icl4Hand(a6) ; Couldnt find an icl8, is there an icl4?
- beq.s DrawBW
- ; draw a icl4 in 8 bit mode
- ; -------
- move.l icl4Hand(a6), -(sp) ; the icl handle
- pea destRect(a6)
- pea portBits(a2) ; for copybits...
- move.w #4, -(sp) ; depth of main screen
- bsr DrawIcls;
- ; -------
- bra.s DoneDrawing
-
- DrawBW: ; Draw the ICN# black and white pattern...
-
- move.l a4,-(sp) ; punch hole with mask
- pea portBits(a2) ; for its portbits
- pea srcRect
- pea destRect(a6)
- move #srcBic,-(sp) ; punch a hole
- clr.l -(sp) ; no clip region
- _CopyBits
-
- sub.l #128,baseAddr(a4)
- move.l a4,-(sp) ; now draw (or) icon
- pea portBits(a2)
- pea srcRect
- pea destRect(a6)
- move #srcOr,-(sp)
- clr.l -(sp)
- _CopyBits
-
- DoneDrawing: ; Dispose of any icl4/icl8 handles...
- cmp.l #0, icl4Hand(a6)
- beq.s release2
- move.l icl4Hand(a6), -(sp)
- _ReleaseResource
- release2:
- cmp.l #0, icl8Hand(a6)
- beq.s OuttaHere
- move.l icl8Hand(a6), -(sp)
- _ReleaseResource
-
- OuttaHere:
- bsr INITCleanup ; cleanup, advance icon location
- movem.l (sp)+,d3-d7/a2-a4 ; restore registers
- unlk a6 ; ditch stack frame
- move.l (sp)+,a0 ; get return address
-
- add.l #initDrawArgs, sp ; ditch incoming args
-
- jmp (a0) ; back to caller
-
- srcRect: dc.w 0,0,32,32 ; for copybits
-
- ENDWITH
- ENDPROC
-
-
-
-
- ;------------------------------------------------------------------------------------------------
- ;
- ; Draws an icl4 or icl8, depending on the size. Assumes a valid handle is passed.
- ; void DrawIcls(Handle iclHand, Rect *destRect, PixMap *DestPM, word pixSize);
- ;
- ; Local varibles:
- ; Handle : GDHand;
- ; PixMap: pixMap;
- ;
- ;------------------------------------------------------------------------------------------------
-
- DrawIcls: PROC EXPORT
- WITH iclVars
-
-
- link a6,#iclVarSize ; create stack frame
- movem.l d7/a1-a4,-(sp) ; save standard registers
-
- ; _Debugger ;
-
- move.w pixSize(a6), d7 ; pixSize into d7
- move.l DestPM(a6), a2 ; take out?
- lea pixMap(a6), a3 ; local PixMap to a3
-
- lea destRect(a6), a1
- move.l destRect(a6), a1
-
- subq.l #4, sp
- Move.w d7, -(sp)
- _GetCTable ; Get system clut..
- Move.l (a7)+, pmTable(a3)
-
- beq.s done ; Couldn't get it... unusual
-
- subq.l #4, sp ; Get their graphic device handle
- _GetGDevice
- Move.l (sp)+, GDHand(a6)
-
- move.l iclHand(a6), A0 ; lock the icl4/8 handle
- _Hlock
- Move.l (a0),pmBaseAddr(a3) ; derefrence icl handle
-
- ext.l d7 ; multiply size * 4
- move.l d7, d0
- asl.l #2, d0 ; mult by 4 for rowbytes
- ori.w #$8000, d0 ; denotes a pixmap
- move.w d0, pmRowBytes(a3); insert into structure
-
- clr.w pmVersion(a3)
- clr.w pmPackType(a3)
- clr.l pmPackSize(a3)
-
- movea.l GDHand(a6), a0 ; Get HRes and VRes
- movea.l (a0), a0 ; derefrence GDHandle
- movea.l gdPMap(a0), a0
- movea.l (a0), a0
- move.l pmHRes(a0), pmHRes(a3)
- move.l pmVRes(a0), pmVRes(a3)
-
- clr.w pmPixelType(a3)
- move.w d7, pmPixelSize(a3)
- move.w #1, pmCmpCount(a3)
- move.w d7, pmCmpSize(a3)
- clr.l pmPlaneBytes(a3)
- clr.l pmReserved(a3)
- clr.l pmBounds(a3) ; top left = 0
- move.l #$00200020, pmBounds+4(a3) ; Dest rect- 0,0,32,32
-
- ; Do copybits...
-
- move.l a3, -(sp) ; the source pixmap
- move.l a2 , -(sp) ; DestPM(a6) ; the dest pixmap
- lea pmBounds(a3) , a0;
- move.l a0, -(sp); ; source rect
- move.l destRect(a6) , -(sp)
- move.w #srcCopy,-(sp);
- move.l a4,-(sp) ; mask
- _CopyBits
- done:
- move.l iclHand(a6),a0
- _HUnlock
- move.l pmTable(a3), -(sp)
- _DisposCTable
-
- move.l a4,-(sp)
- _DisposeRgn
-
- movem (sp)+, d7/a1-a4
- unlk a6 ; ditch stack frame
- move.l (sp)+, a0 ; get return address
- add.l #iclDrawArgs, sp ; ditch incoming arguments
- jmp (a0) ; return to caller
-
- ENDWITH
-
- ENDPROC
-
- END
-